The caller is from the reducer i am using for the app to dispatch actions for changing the state of the app
The fn
const AddFriendFirebase = async (name = "", current_uid) => {
console.log("ASdf one");
const { uid } = await getUserFromName(name);
console.log("ASdf");
createMessageDoc(current_uid, uid);
}
The caller
case ADD_FRIEND: {
AddFriendFirebase(payload, state.current_uid);
return state;
}
get UserFromName Fn
const getUserFromName = async (name) => {
console.log("get name fn");
const q = query(collection(db, "users"), where("user_name", "==", name));
const snapshot = await getDocs(q);
if (!snapshot.docs[0]) {
throw console.error("user not found!");
}
const user = snapshot.docs[0].data();
return user;
};